
    <?php $errores=$_SESSION["erroresForm"];
	$formulario=$_SESSION["formulario"];
			if(!isset($formulario)||$formulario["reset"]){
				$formulario=array();
				$formulario["username"]="";
				$formulario["passwd"]="";
				$formulario["rpt_passwd"]="";
				$formulario["dni"]="";
				$formulario["letra"]="";
				$formulario["name"]="";
				$formulario["surname"]="";
				$formulario["email"]="";
				$formulario["rptemail"]="";
				$formulario["address"]="";
				$formulario["zipCode"]="";
				$formulario["city"]="";
				$formulario["state"]="";
				
			}
			$_SESSION["formulario"];
			if(isset($errores) && is_array($errores)){
				echo "<div id='errores' class='error'>";
				foreach($errores as $error){
					echo "$error<br/>";
				}
				echo "</div>";
			}
			unset($_SESSION['erroresForm']);
			?>
    	<div id="errores">
    	
    	</div>
    	<div id="RegisterFormP">
            <form action="RegisterValidation.php" method="post" enctype="multipart/form-data" onsubmit="return validarErrores();" onreset="username.value = ''">
                <fieldset>
                    <legend>
                        Datos de la Cuenta
                    </legend>
                    <label>
                        Nombre de Usuario: <input id="nombreUsuario" type="text" name="username" size="15" value="<?php echo($formulario['username']);?>">
                    </label>
                    <br>
                    <label>
                        Contraseña: <input id="contrasena" type="password" name="passwd" size="15">
                    </label>
                    <br>
                    <label>
                        Repita Contraseña: <input id="rpt_contrasena" type="password" name="rpt_passwd" size="15" onchange="validarContrasena()">
                    </label>
                </fieldset>
                <fieldset>
                    <legend>
                        Datos personales
                    </legend>
                    <label>
                        D.N.I.: <input id="dni" type="text" name="dni" size="8" maxlength="8" onchange="digitosDNI()" onkeydown="return validarN(event);" value="<?php echo($formulario['dni']);?>">
                    </label>
                    <label>
                    -<input id="letra" type="text" name="letra" size="1" maxlength="1" onchange="validarDNI()" value="<?php echo(strtoupper($formulario['letra']));?>">
                    </label>
                    <br>
                    <label>
                        Nombre: <input id="nombre" type="text" name="name" size="20" value="<?php echo($formulario['name']);?>">
                    </label>
                    <br>
                    <label>
                        Apellidos: <input id="apellidos" type="text" name="surname" size="30" value="<?php echo($formulario['surname']);?>">
                    </label>
                    <br>
                    <label>
                        E-mail: <input id="email" type="text" name="email" size="30"  value="<?php echo($formulario['email']);?>">
                    </label>
                    <br>
                    <label>
                        Repita E-mail: <input id="rptemail" type="text" name="rptemail" size="30" onchange="validarCorreo()" value="<?php echo($formulario['rptemail']);?>">
                    </label>
                    <br>
                    <label>
                        Dirección: <input id="direccion" type="text" name="address" size="40" value="<?php echo($formulario['address']);?>">
                    </label>
                    <br>
                    <label>
                        C.P.: <input id="cp" type="text" name="zipCode" maxlength="5" size="5" onkeydown="return validarN(event);" value="<?php echo($formulario['zipCode']);?>">
                    </label>
					<label>Localidad: <input id="localidad" type="text" name="city" size="18" onkeydown="return validarL(event);" value="<?php echo($formulario['city']);?>"></label>	
					<label>Provincia: <input id="provincia" type="text" name="state" size="18" onkeydown="return validarL(event);" value="<?php echo($formulario['state']);?>"></label>
					<br>
					Fecha nacimiento:
                    <br>
                    <label>
                        Dia: 
                        <select id="dnacimiento" title="Dia de nacimiento" size="1" name="dnacimiento">
                            <option selected="selected">1</option>
                            <option>2</option>
                            <option>3</option>
                            <option>4</option>
                            <option>5</option>
                            <option>6</option>
                            <option>7</option>
                            <option>8</option>
                            <option>9</option>
                            <option>10</option>
                            <option>11</option>
                            <option>12</option>
                            <option>13</option>
                            <option>14</option>
                            <option>15</option>
                            <option>16</option>
                            <option>17</option>
                            <option>18</option>
                            <option>19</option>
                            <option>20</option>
                            <option>21</option>
                            <option>22</option>
                            <option>23</option>
                            <option>24</option>
                            <option>25</option>
                            <option>26</option>
                            <option>27</option>
                            <option>28</option>
                            <option>29</option>
                            <option>30</option>
                            <option>31</option>
                        </select>
                    </label>
                    <label>
                        Mes: 
                        <select id="mnacimiento" title="Mes de nacimiento" size="1" name="mnacimiento">
                            <option value="1" selected="selected">Enero</option>
                            <option value="2">Febrero</option>
                            <option value="3">Marzo</option>
                            <option value="4">Abril</option>
                            <option value="5">Mayo</option>
                            <option value="6">Junio</option>
                            <option value="7">Julio</option>
                            <option value="8">Agosto</option>
                            <option value="9">Septiembre</option>
                            <option value="10">Octubre</option>
                            <option value="11">Noviembre</option>
                            <option value="12">Diciembre</option>
                        </select>
                    </label>
                    <label>
                        Año: 
                        <select id="anacimiento" title="Año de nacimiento" size="1" name="anacimiento">
                            <option selected="selected">1940</option>
                            <option>1940</option>
                            <option>1941</option>
                            <option>1942</option>
                            <option>1943</option>
                            <option>1944</option>
                            <option>1945</option>
                            <option>1946</option>
                            <option>1947</option>
                            <option>1948</option>
                            <option>1949</option>
                            <option>1950</option>
                            <option>1951</option>
                            <option>1952</option>
                            <option>1953</option>
                            <option>1954</option>
                            <option>1955</option>
                            <option>1956</option>
                            <option>1957</option>
                            <option>1958</option>
                            <option>1959</option>
                            <option>1960</option>
                            <option>1961</option>
                            <option>1962</option>
                            <option>1963</option>
                            <option>1964</option>
                            <option>1965</option>
                            <option>1966</option>
                            <option>1967</option>
                            <option>1968</option>
                            <option>1969</option>
                            <option>1970</option>
                            <option>1971</option>
                            <option>1972</option>
                            <option>1973</option>
                            <option>1974</option>
                            <option>1975</option>
                            <option>1976</option>
                            <option>1977</option>
                            <option>1978</option>
                            <option>1979</option>
                            <option>1980</option>
                            <option>1981</option>
                            <option>1982</option>
                            <option>1983</option>
                            <option>1984</option>
                            <option>1985</option>
                            <option>1986</option>
                            <option>1987</option>
                            <option>1988</option>
                            <option>1989</option>
                            <option>1990</option>
                            <option>1991</option>
                        </select>
                    </label>
                </fieldset>
                <div id="regsubmitP">
                    <button id="submitReg" type="submit">
                        Enviar
                    </button>
                </div>
				<div id="regclearP">
                    <button id="clear" type="reset" name="reset">
                        Borrar
                    </button>
                </div>               
				
          </form>
        </div>
        
   